Public Class edituser
    Inherits System.Web.UI.Page
    'Protected WithEvents TheHeader1 As adm_header
    Public Msg, RoleID As String
    Protected WithEvents sUID As System.Web.UI.WebControls.TextBox
    Protected WithEvents password As System.Web.UI.WebControls.TextBox
    Protected WithEvents firstname As System.Web.UI.WebControls.TextBox
    Protected WithEvents lastname As System.Web.UI.WebControls.TextBox
    Protected WithEvents location As System.Web.UI.WebControls.TextBox
    Protected WithEvents Phone As System.Web.UI.WebControls.TextBox
    Protected WithEvents Ext As System.Web.UI.WebControls.TextBox
    Protected WithEvents Email As System.Web.UI.WebControls.TextBox
    Protected WithEvents ch As System.Web.UI.WebControls.CheckBox
    Public aUserSession(13) As String
    Public objvalid As New gaValidation
    Public imgpath, currtURL As String
    Public sVID As String
    Public nCompanyID As Integer
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        objvalid.getURL(Request.Url.ToString, imgpath, currtURL)
    End Sub
    'Public Function GetUserData() As String()
    'oUserData = Server.CreateObject("viaUserManagement.UserManagement")
    'oUserData.DBConnectString = Application("DSN")
    'bLocked = oUserData.LockedStatus(sUID, sVID, nCID)

    'Rs = oUserData.AddUserConfirm(sUID, sVID, nCID)
    ''Set oUserData				= Nothing
    'If Not Rs.EOF Then
    '    sUID = SafeString(Rs("User_ID"))
    '    sVID = SafeString(Rs("viaklix_id"))
    '    nCID = CInt(Rs("company_id"))
    '    password = SafeString(Rs("password"))
    '    First_name = SafeString(Rs("First_name"))
    '    Last_name = SafeString(Rs("Last_name"))
    '    Location = SafeString(Rs("Location"))
    '    Phone = SafeString(Rs("Phone"))
    '    ext = SafeString(Rs("Ext"))
    '    Supervisor = SafeString(Rs("Supervisor"))
    '    Active = UCase(safestring(Rs("Active")))
    '    Email = SafeString(Rs("Email_Address"))
    '    RoleID = CInt(Rs("RoleID"))
    'End If
    'oLockStatus = Server.CreateObject("viaUserManagement.UserManagement")
    'oLockStatus.DBConnectString = Application("DSN")
    'bLockStatus = oLockStatus.LockedStatus(sUID, sVID, nCID)
    ''set oLockStatus = nothing
    'If bLockStatus Then
    '    Msg = "This account has been locked."
    '    oLockStatus = Nothing
    'Else
    '    oLockStatus = Nothing
    'End If


    'End Function
    'Public Function DispSupervisor() As String
    ' --- CURRENT USER CANNOT CHANGE THEIR OWN SUPERVISOR
    ' --- OR SUPERVISOR HAS NOT BEEN INITALLY ASSIGNED
    ' --- xiuqin modified current user can change his supervisor to his subordinates user
    'if Supervisor = ""  then %>
    '				<tr>
    '					<td colspan=2>
    '						<input type="hidden" name="supervisor" value="<%=Supervisor%>">
    '						<input type="hidden" name="supervisorold" value="<%=Supervisor%>">
    '					</td>
    '				</tr>   <%
    'else
    '        ' --- CREATE THE DROP DOWN LIST %>
    '				<tr>
    '					<td><font face="verdana, arial, helvetica" size="2">Supervisor : </font></td>
    '					<td>
    '					<%
    '        oSupervisors = CreateObject("viaUserManagement.UserManagement")
    '        oSupervisors.DBConnectString = Application("DSN")
    '        aUsersSorted = oSupervisors.GetMerchantUsers(aUserSession(cINVIDCONTEXT), Supervisor)
    '        oSupervisors = Nothing
    '        AdminGroupSuper = ""

    '        'For i = 0 To UBound(aUsersSorted)
    '        '    For j = 0 To UBound(aUsersSorted, 2)
    '        '        response.write (aUsersSorted(i, j) & " / ")
    '        '    Next
    '        '    response.write ("<p>")
    '        'Next
    '        If IsArray(aUsersSorted) Then
    '            sHTML = ""
    '            sHTML = sHTML & "<select name=""Supervisor"">" & vbCrLf

    '            '--- LOOPS THROUGH ARRAY FOR EACH ELEMENT
    '            '--- aUsersSorted(i,0) : CONTAINS THE UID OF EACH POTENTIAL SUPERVISOR
    '            '--- aUsersSorted(i,1) : CONTAINS UID OF SUPERVISOR OF PERSON SHOWN IN (i,0)
    '            '--- aUsersSorted(i,2) : CONTAINS AN 'ACCESS' FLAG -- NOT USED IN THIS CONTEXT
    '            '--- aUsersSorted(i,3) : CONTAINS A USER LEVEL FLAG
    '            '--------------------------------------------------------

    '            For i = 0 To UBound(aUsersSorted)
    '                If aUsersSorted(i, 0) = aUserSession(cUSER_ID) Then
    '                    LevelAdmin = safestring(aUsersSorted(i, 1))
    '                    Exit For
    '                End If
    '            Next

    '            If (LevelAdmin = "") Then
    '                LevelAdmin = aUserSession(cUSER_ID)
    '            End If

    '            For i = 0 To UBound(aUsersSorted)
    '                If aUsersSorted(i, 0) = LevelAdmin Then
    '                    AdminGroupSuper = safestring(aUsersSorted(i, 1))
    '									sLevelMarker = string(aUsersSorted(i,3) * 2,"^")
    '                    Exit For
    '                End If
    '            Next

    '            'response.write ("<p><b>Management Hierarchy:</b><br>")

    '            sHTML = sHTML & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "<option value=""" & LevelAdmin & """>" & sLevelMarker & LevelAdmin & "</option>" & vbCrLf
    '            FindSubordinates(LevelAdmin)

    '            'response.write ("<p>&nbsp;")
    '            sHTML = sHTML & vbTab & vbTab & vbTab & vbTab & vbTab & "</select>"
    '            sHTML = Replace(sHTML, "^", "&nbsp;")
    '            '--- END DROP DOWN LIST

    '            '--- IF ANYTHING WAS ADDED TO THE DROP DOWN LIST THEN DISPLAY THE LIST
    '            '--- OTHERWISE DISPLAY NOTHING
    '							response.write(sHTML) %>

    '						<input type="hidden" name="supervisorold" value="<%=Supervisor%>">
    '						<%
    '            'response.write ("<p>AdminGroupSuper = " & AdminGroupSuper & " / AdminGroup = " & LevelAdmin & "<p>")
    '        Else
    '						%>
    '							<font face="verdana, arial, helvetica" size="2">Could not retrieve user list.</font>
    '							<input type="hidden" name="supervisor" value="<%=Supervisor%>">
    '							<input type="hidden" name="supervisorold" value="<%=Supervisor%>">	<%
    '						end if %>
    '					</td>
    '				</tr>
    '			<% end if %>

    'End Function
    'Public Function FindSubordinates(ByVal Manager) As String


    '    For indx1 = 0 To UBound(aUsersSorted)
    '        If aUsersSorted(indx1, 1) = Manager Then
    'sLevelMarker = string(aUsersSorted(indx1,3) * 2,"^")
    '            'response.write (Manager & " manages " & aUsersSorted(indx1, 0) & "<br>")
    '            If (aUsersSorted(indx1, 0) <> sUID And safestring(aUsersSorted(indx1, 1)) <> sUID) Then
    '                If aUsersSorted(indx1, 0) = supervisor Then
    '                    sHTML = sHTML & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "<option value=""" & aUsersSorted(indx1, 0) & """ selected>" & sLevelMarker & aUsersSorted(indx1, 0) & "</option>" & vbCrLf
    '                Else
    '                    sHTML = sHTML & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "<option value=""" & aUsersSorted(indx1, 0) & """>" & sLevelMarker & aUsersSorted(indx1, 0) & "</option>" & vbCrLf
    '                End If

    '                FindSubordinates(aUsersSorted(indx1, 0))
    '            End If
    '            sLevelMarker = ""
    '        End If
    '    Next
    'End Function


    Private Sub btnUnloc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'case "UNLO"
        '        '===2/25/02 xiuqin add unlock account
        '        oLockStatus = Server.CreateObject("viaUserManagement.UserManagement")
        '        oLockStatus.DBConnectString = Application("DSN")
        '        oLockStatus.SESSION_USER_ID = aUserSession(cUSER_ID)
        '        oLockStatus.SESSION_VIAKLIX_ID = aUserSession(cVIAKLIX_ID)
        '        oLockStatus.SESSION_COMPANY_ID = aUserSession(cCOMPANY_ID)
        '        oLockStatus.ServerIP = safestring(Request.ServerVariables("LOCAL_ADDR"))
        '        oLockStatus.ServerTime = safestring(Now())
        '        oLockStatus.SourceIP = safestring(Request.ServerVariables("REMOTE_ADDR"))

        '        oLockStatus.UnLockAccount(sUID, sVID, nCID)
        '        Msg = ""

        '        oLockStatus = Nothing

    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'case "UP"

        '       oUpdate = Server.CreateObject("viaUserManagement.UserManagement")
        '       oValidator = Server.CreateObject("viaFormValidator.General")

        '       If Len(Request("email")) <> 0 Then
        '           ValidEmail = oValidator.general_checkemail(Request("email"), "E-mail Address")
        '           If Len(ValidEmail) <> 0 Then
        '               Msg = ValidEmail & "."
        '           End If
        '       End If
        '       oValidator = Nothing

        '       Msg = Trim(Msg)
        '       If Len(Msg) = 0 Then
        '           oUpdate.DBConnectString = Application("DSN")
        '           oUpdate.SESSION_VIAKLIX_ID = aUserSession(cVIAKLIX_ID)
        '           oUpdate.SESSION_USER_ID = aUserSession(cUSER_ID)
        '           oUpdate.SESSION_COMPANY_ID = aUserSession(cCOMPANY_ID)
        '           oUpdate.password = SafeString(Request("password"))
        '           oUpdate.OrigPassword = SafeString(Request("passwordold"))

        '           oUpdate.firstnameold = SafeString(Request("firstnameold"))
        '           oUpdate.firstname = SafeString(Request("firstname"))
        '           oUpdate.lastnameold = SafeString(Request("lastnameold"))
        '           oUpdate.lastname = SafeString(Request("lastname"))
        '           oUpdate.locationold = Safestring(Request("locationold"))
        '           oUpdate.location = Safestring(Request("location"))
        '           oUpdate.phoneold = SafeString(Request("Phoneold"))
        '           oUpdate.phone = SafeString(Request("Phone"))
        '           oUpdate.Extold = SafeString(Request("extold"))
        '           oUpdate.Ext = SafeString(Request("ext"))
        '           oUpdate.RoleIDold = CInt(Request("RoleIDold"))
        '           oUpdate.RoleID = 1
        '           oUpdate.supervisorold = SafeString(Request("supervisorold"))
        '           oUpdate.supervisor = SafeString(Request("supervisor"))
        '           oUpdate.Activeold = BoolToYN(Request("Activeold"))
        '           oUpdate.Active = BoolToYN(Request("Active"))
        '           oUpdate.Emailold = SafeString(Request("emailold"))
        '           oUpdate.Email = SafeString(Request("email"))
        '           UpdateOk = oUpdate.EditUser(sUID, CInt(nCID), sVID, "Update")
        '           oUpdate = Nothing

        '           If UpdateOk = "OK" Then
        '               Response.Redirect("default.asp")
        '           Else
        '               Msg = UpdateOk
        '           End If
        '       End If
        '    end select

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Response.Redirect("")
    End Sub

    Private Sub BtnEditTerm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Response.Redirect("adm_EditTerminalNumbers.asp?s=1")
    End Sub

    Private Sub btnEditRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Response.Redirect("adm_EditRight.asp")
    End Sub
End Class
